﻿using EMoney.IStock.Client.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using ThinkDev.Logging;

namespace EMoney.IStock.Client.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //启动日志模块
            LoggerGlobal.GlobalInit();
            //启动监控模块
            EMoney.Monitor.Client.Global.Init();
        }

        protected void Application_Error()
        {
            //Tip:统一捕获未处理的异常
            Exception ex = Server.GetLastError();
            LogManager.DefaultLogger.Error(ThinkDev.Logging.LogConvert.ParseWebEx(ex), "EMoney.IStock.Client.Web捕获未处理异常");
            EMoney.Monitor.Client.ExceptionMonitor.PostException(ex, "Application_Error");
            Server.ClearError();
        }
    }
}